import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from "element-ui";
import BaiduMap from "vue-baidu-map";
import Vant from "vant";
import Mui from "vue-awesome-mui";
import axios from "axios";
import IdCard from "../static/js/IdCard";
import "@/assets/css/reset.css";
import "@/assets/css/vant.css";
import "./mock/mockServer";

Vue.use(Mui);
Vue.use(Vant);
Vue.prototype.validid = IdCard;
Vue.use(ElementUI);
// Vue.use(VueResource);
Vue.use(BaiduMap, {
  ak: "9MXMGoPNlcWUEUr8SsTgTsvRCWdCAQNH",
});

// 添加请求拦截器
axios.interceptors.request.use(
  function (config) {
    // 判断是否存在token,如果存在将每个页面header添加token
    if (localStorage.getItem("token")) {
      config.headers.common["token"] = localStorage.getItem("token");
    }
    return config;
  },
  function (error) {
    router.push("/login");
    return Promise.reject(error);
  }
);

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
